#include <cstdio>

void swap(int *pa,int *pb);

int main(){
    int a = 10;
    int b = 20;
    int * pa = &a;
    int * pb = &b;
    int ** ppb = &pb;
    printf("a: %d\n",a);
    printf("%p\n",ppb);
    printf("sizeof: %d\n",sizeof(ppb));
    // swap(pa,pb);// 与下边这行等价 
    swap(&a,&b);
    printf("a,b:%d,%d\n",a,b);

    int arr[] = {9,1,2,3,4,5};
    // int * parr = &arr[0];// 与下边这行等价 
    int * parr = arr;
    printf("address arr: %p\n",arr);
    printf("address parr: %p\n",parr);
    // parr++; // 指针向后移动4个字节(int占4个字节)
    printf("arr[0]: %d\n",*parr);
    for(int i=0;i<6;i++){
        printf("arr[%d]=%d\n",i,*parr++);
    }
    return 0;
}

// 按引用传递会修改实参的值
void swap(int *pa, int *pb){
    int temp = *pa;
    *pa = *pb;
    *pb = temp;
}